/*******************************************************************************
* 
* A simple lzma86 warpper class
* 
* 
******************************************************************************/
#pragma once
#include "noria.h"
using std::istream;
using std::ostream;

namespace noria{ namespace io
{
    class LzmaHelper
    {
    public:
        // ------------------------------------------------------------------------------------
        // compress from file to file
        //
        // olen - in: the address of output length. olen == NULL or *olen == 0 will cause
        //              the algorithm to create default sized buffer as output data,
        //              otherwise, it create *olen sized buffer as output data.
        //              make sure the length is enough for the output buffer or pass 0 to it.
        //      - out: if olen != NULL, it returns the processed dest length
        // ------------------------------------------------------------------------------------
        static bool compress(const wstring& source, const wstring& dest, size_t* olen = NULL, bool append = false);

        // ------------------------------------------------------------------------------------
        // compress from istream to ostream
        //
        // olen - see above
        // ------------------------------------------------------------------------------------
        static bool compress(istream& source, ostream& dest, size_t* olen = NULL);

        // ------------------------------------------------------------------------------------
        // compress from buffer to buffer
        //
        // olen - see above, but olen is not optional and has to be passed
        // ------------------------------------------------------------------------------------
        static bool compress(cbyte_ptr source, size_t ilen, byte_ptr dest, size_t* olen);

        // ------------------------------------------------------------------------------------
        // decompress from file to file
        //
        // olen - see 'compress'
        // ------------------------------------------------------------------------------------
        static bool decompress(const wstring& source, const wstring& dest, size_t* olen = NULL, bool append = false);

        // ------------------------------------------------------------------------------------
        // decompress from istream to istream
        //
        // olen - see above
        // ------------------------------------------------------------------------------------
        static bool decompress(istream& source, ostream& dest, size_t* olen = NULL);

        // ------------------------------------------------------------------------------------
        // decompress from buffer to buffer
        //
        // olen - see above, but olen is not optional and has to be passed
        // ------------------------------------------------------------------------------------
        static bool decompress(cbyte_ptr source, size_t ilen, byte_ptr dest, size_t* olen);

    };
}}
